//
//  LeftViewController.m
//  侧滑菜单demo
//
//  Created by 杨森林 on 15/8/21.
//  Copyright (c) 2015年 Yangsl. All rights reserved.
//

#import "LeftViewController.h"
#import <SlideNavigationController.h>
#import "LeftTableViewCell.h"
#import "LoginViewController.h"
@interface LeftViewController ()<UITableViewDelegate,UITableViewDataSource>{
    UITableView * leftTableView;
    NSArray * itemArry;
    NSMutableArray * imageArray;
}

@end

@implementation LeftViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 70, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - 70) style:UITableViewStylePlain];
    [self initDataSource];
    [self.view addSubview:leftTableView];
    leftTableView.delegate = self;
    leftTableView.dataSource =self;
}
- (void)initDataSource
{
    itemArry = [NSArray arrayWithObjects:@"个人 登陆/注册",@"商家登陆/入驻",@"设置", @"意见反馈",@"退出登陆",nil];
    for (int i=0; i<5; i++) {
        UIImage * image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"set-%d" ofType:@"png"]];
        [imageArray addObject:image];
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString * cellID = @"leftCell";
    LeftTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"LeftTableViewCell" owner:nil options:nil] lastObject];
        cell.itemsLabel.text = itemArry[indexPath.row];
        [cell.itemsLabel setFont:[UIFont systemFontOfSize:18]];
        cell.iconImageView.image = imageArray[indexPath.row];
    }
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [itemArry count];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    switch (indexPath.row) {
//        case 0:
//            <#statements#>
//            break;
//            
//        default:
//            break;
//    }
    if (indexPath.row == 0) {
        LoginViewController * loginVC = [[LoginViewController alloc] init];
        [[SlideNavigationController sharedInstance] switchToViewController:loginVC withCompletion:nil];
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
